let geolocation = null;

// 获取当前定位
export function selfLocation(params) {
  if(!geolocation) {
    geolocation = new AMap.Geolocation({
      enableHighAccuracy: false,
      timeout: 10000,
      buttonOffset: new AMap.Pixel(10, 20),
      zoomToAccuracy: true,     
      buttonPosition: 'RB',
      showCircle: false,
      showMarker: false,
    })
  }
  params.map.addControl(geolocation);
  geolocation.getCurrentPosition(function(status,result) {
    if(status=='complete') {
      params.onComplete && params.onComplete(result);
    }else{
      params.onError && params.onError(result);
    }
  })
}
